<template>
    <div class="Preson">
  <h2>当前求和：{{ sum }}</h2>
  <button @click="changeSum">sum++</button>
    </div>
</template>

<script lang="ts" setup>
import { ref,onBeforeMount,onMounted,onBeforeUpdate, onUpdated, onBeforeUnmount, onUnmounted } from 'vue';

let sum = ref(0)
function changeSum() {
    sum.value++
}

// 创建 
console.log('创建');

// 挂载
onBeforeMount(() => {
    console.log('挂在前');
    
})

onMounted(() => {
    console.log('挂载完毕');
    
})
// 更新
onBeforeUpdate(() => {
    console.log('更新前');
    
})

onUpdated(() => {
    console.log('更新完毕');
    
})
// 卸载
onBeforeUnmount(() => {
    console.log('卸载前');
    
})

onUnmounted(() => { 
    console.log('卸载完毕');
    
})
</script>

<style scoped>
.Preson {
    background-color: #ddd;
    box-shadow: 0 0 10px;
    border-radius: 10px;
    padding: 20px;
}

button { 
    margin: 0 10px;
}
</style>